package lib.list;

import lombok.SneakyThrows;
import org.junit.Test;

import java.util.ArrayList;
import java.util.concurrent.*;

/**
 * @author: User
 * @date: 2022/11/10
 * @Description:此类用于xxx
 */
public class BlockingQueueTest {


    @SneakyThrows
    @Test
    public void test01(){
        BlockingQueue<Runnable> q=new ArrayBlockingQueue<>(10);
        q.put(new Runnable() {
            @Override
            public void run() {
                System.out.println("q");
            }
        });
        ArrayList a=new ArrayList();


        BlockingQueue<Runnable> q2=new LinkedBlockingQueue<>(10);
        q.put(new Runnable() {
            @Override
            public void run() {
                System.out.println("q2");
            }
        });
        ArrayList b=new ArrayList();
        BlockingQueue<Runnable> q3=new SynchronousQueue<>(false);
        q.put(new Runnable() {
            @Override
            public void run() {
                System.out.println("q3");
            }
        });
        ArrayList c=new ArrayList();
        BlockingQueue<Runnable> q4=new DelayQueue();
        q.put(new Runnable() {
            @Override
            public void run() {
                System.out.println("q4");
            }
        });
        ArrayList d=new ArrayList();
        q.drainTo(a);
        q2.drainTo(b);
        q3.drainTo(c);
        q4.drainTo(d);
    }
}
